<?php
namespace App\Http\Controllers;

use App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Service\PythonService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Validator;

class PythonController extends BaseController
{
    
    public $repository;
    public $LianJieJieXi_url="http://test-node.lottefuture.com/smzdm/?url=https:";
    public function __construct(PythonService $repository)
    {
        parent::__construct();
        $this->repository = $repository;
    }
    //链接解析-值得买
    public function  SmzdmLianJieJieXi(Request $request){
        $data=[
            'shop_buy_url'=>$request->json("shop_buy_url"),

        ];
        $result_arr=$this->repository->SmzdmLianJieJieXi($request,$data);
        if($result_arr['code']==0){

             $this->error($result_arr['msg']);
        }else{
             $this->success($result_arr['result'], $result_arr['msg']);
        }

        
    }
    //值得买-根据产品id获取佣金
    public function getMoneyRate(Request $request)
    {
        $data=[
            'product_id'=>$request->json("product_id"),
            'platform_name'=>$request->json("platform_name"),

        ];
        $result_arr=$this->repository->getMoneyRate($request,$data);
        $this->success($result_arr);
    }

    public function categoryBrand(Request $request)
    {
        $data=[
            'original_category_name'=>$request->json("original_category_name"),
            'original_brand_name'=>$request->json("original_brand_name"),

        ];
        $result_arr=$this->repository->categoryBrand($request,$data);
        $this->success($result_arr);
    }

    //获取商品详情  
/*    "京东": "http://cgi-bin.lottefuture.com/python/jd-goods-query.php",
    "淘宝": "http://cgi-bin.lottefuture.com/python/taobao-goods-query.php",
    "拼多多":"http://cgi-bin.lottefuture.com/python/pdd-goods-query.php",
    "唯品会":"http://cgi-bin.lottefuture.com/python/vipshop-goods-query.php",*/
    public function get_goods_detail(Request $request)
    {
        $data=[
            'platform_name'=>$request->json("platform_name"),
            'product_id'=>$request->json("product_id"),

        ];
        $result_arr=$this->repository->get_goods_detail($request,$data);
    }
    //根据链接获取商品详情
    public function fetch_url_goods_detail(Request $request)
    {
        $data=[
            'shop_buy_url'=>$request->json("shop_buy_url"),
        ];
        
        $result_arr=$this->repository->fetch_url_goods_detail($request,$data);
        $this->success($result_arr);
    }
    
}
